A full-stack e-commerce application with React frontend, Express.js backend, MongoDB database, and JWT authentication.
- User Authentication: JWT-based authentication with two user roles (customer and owner)
- Product Management: Store owners can add, edit, and delete products
- Shopping Cart: Customers can add products to cart and checkout
- Order Management: View order history and details
- Responsive Design: Mobile-friendly UI
ecommerce-app/
├── client/ # Frontend React application
├── server/ # Backend Express application
├── .gitignore
├── package.json
└── README.md
- Node.js (v14+)
- MongoDB
- npm or yarn
git clone https://github.com/yourusername/estore-app.git
cd estore-app-
Navigate to the server directory:
cd server -
Install dependencies:
npm install
-
Create a
.envfile in the server directory with the following variables:PORT=5000 MONGODB_URI=mongodb://localhost:27017/ecommerce JWT_SECRET=your_jwt_secret_key -
Start the backend server:
npm run dev
- Updated
multerto1.4.4-lts.1to address CVE-2022-24434. - Updated
jsonwebtokento9.0.2to resolve multiple vulnerabilities.
- Updated
nodemonto the latest version to address vulnerabilities insemver.
-
Navigate to the client directory:
cd ../client -
Install dependencies:
npm install
-
Create a
.envfile in the client directory with:REACT_APP_API_URL=http://localhost:5000/api -
Start the frontend development server:
npm start
-
Open your browser and navigate to
http://localhost:3000
- Updated
axiosto the latest version to address security vulnerabilities. - Updated
react-scriptsto the latest version to resolve vulnerabilities innth-checkandpostcss.
After setting up the application, you can use these default users for testing:
- Email: owner@example.com
- Password: owner123
- Email: customer@example.com
- Password: customer123
POST /api/auth/register- Register a new userPOST /api/auth/login- Login and get JWT token
GET /api/products- Get all productsGET /api/products/:id- Get a single productPOST /api/products- Add a new product (owner only)PUT /api/products/:id- Update a product (owner only)DELETE /api/products/:id- Delete a product (owner only)
GET /api/cart- Get user's cartPOST /api/cart- Add item to cartPUT /api/cart/:itemId- Update cart item quantityDELETE /api/cart/:itemId- Remove item from cart
GET /api/orders- Get user's ordersPOST /api/orders- Create a new orderGET /api/orders/:id- Get order detailsGET /api/admin/orders- Get all orders (owner only)PUT /api/admin/orders/:id- Update order status (owner only)
- Frontend: React, Redux, React Router, Axios, Tailwind CSS
- Backend: Node.js, Express.js, MongoDB, Mongoose
- Authentication: JSON Web Tokens (JWT)
- Others: Bcrypt (password hashing), Multer (file uploads)